package com.interview.domain;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class Cart {
    private String userName;
    private Map<String,Integer>cart = new HashMap<>();

    public Cart(String userName) {
        this.userName = userName;
    }

    public Cart() {
    }

    public void addToCart(String name, Integer quantity){
        cart.put(name,cart.getOrDefault(name,0)+quantity);
    }

    public void clearCart(){
        this.cart.clear();
    }
}
